#!/bin/bash
echo "  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND"> ./test.txt       
while :
do
    echo "`date +%s`" >> ./test.txt
    oldifs="$IFS"
    IFS=$'\n'
    for file in `top -b -n 1 | grep box`
    do
        IFS=$oldifs
        topary=($file)
        str=$(cat /proc/${topary[0]}/statm)
        array=($str)
        topary[5]=$((${array[1]}/256))
        echo ${topary[@]} >> ./test.txt
        IFS=$'\n'
    done
    IFS="$oldifs"

    sleep 1
done